/*
 * MonomialProcedure.java
 *
 * Created on May 4, 2005, 7:27 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package com.milowski.monos.scheme;

import gnu.mapping.*;
import gnu.math.*;
import gnu.lists.*;
import com.milowski.monos.*;
import com.milowski.monos.monomial.*;

/**
 *
 * @author R. Alexander Milowski
 */
public class List2MonomialProcedure extends Procedure1
{
   
   /** Creates a new instance of MonomialProcedure */
   public List2MonomialProcedure()
   {
      super("list->monomial");
   }
   
   public List2MonomialProcedure(String name)
   {
      super(name);
   }
   
   public Object apply1(Object obj) {
      LList list = (LList)obj;
      int size = LList.length(list);
      Monomial m = new Monomial(size);
      short [] values = m.getValues();
      for (int i=0; i<size; i++) {
         IntNum inum = (IntNum)list.get(i);
         values[i] = (short)inum.intValue();
      }
      return m;
   }
   
}
